#pragma once
#include "qvector.h"
#include "MyVertex.h"

namespace PUMA
{
	struct Geometry
	{
		Geometry(void);

		QVector<MyVertex> vertices;
		QVector<GLuint> indices;
		void appendFaceted(const QVector3D &a, const QVector3D &n);
		void appendTriangleIndices(const int a, const int b, const int c);
		void finalize();
		void initBuffers(QGLBuffer::UsagePattern usage);
		void bind();
		void release();

		QGLBuffer mVertexVBO;
		QGLBuffer mIndexVBO;

		bool isInited;
	};

	class Patch
	{
	public:
		~Patch(void);

		Patch(Geometry *);
		void translate(const QVector3D &t);
		void rotate(qreal deg, QVector3D axis);
		void draw(QGLShaderProgram& shaderProgram, QMatrix4x4& viewMatrix, QMatrix4x4& projectionMatrix) const;
		void addTri(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &n);

		QMatrix4x4 modelMatrix;
		Geometry *geom;
	};
}